package com.xingkeduo.dto;

import com.xingkeduo.util.pojo.enums.YesNoEnum;
import io.micrometer.core.instrument.util.StringUtils;

import java.math.BigDecimal;

/**
 * 发型师服务表
 *
 * @author gaozifeng
 * @time 2019年2月18日17:45:29
 * @description
 */
public class CraftsmanServiceTO implements Comparable<CraftsmanServiceTO>{

    private Long craftsmanId;

    private long shopId;

    private long serviceId;

    private YesNoEnum status;

    private BigDecimal prices;
    
    private String nearlyAppointmentDate;
    
    

    public String getNearlyAppointmentDate() {
		return nearlyAppointmentDate;
	}

	public void setNearlyAppointmentDate(String nearlyAppointmentDate) {
		this.nearlyAppointmentDate = nearlyAppointmentDate;
	}

	public YesNoEnum getStatus() {
        return status;
    }

    public CraftsmanServiceTO setStuatus(YesNoEnum status) {
        this.status = status;
        return this;
    }

    public long getShopId() {
        return shopId;
    }

    public CraftsmanServiceTO setShopId(long shopId) {
        this.shopId = shopId;
        return this;
    }

    public BigDecimal getPrices() {
        return prices;
    }

    public CraftsmanServiceTO setPrices(BigDecimal prices) {
        this.prices = prices;
        return this;
    }

    public Long getCraftsmanId() {
        return craftsmanId;
    }

    public CraftsmanServiceTO setCraftsmanId(Long craftsmanId) {
        this.craftsmanId = craftsmanId;
        return this;
    }

    public long getServiceId() {
        return serviceId;
    }

    public CraftsmanServiceTO setServiceId(long serviceId) {
        this.serviceId = serviceId;
        return this;
    }

    //排序规则：时间相等  价格低的靠前，时间不相等  时间小的靠前。 -1 靠前  1靠后
	@Override
	public int compareTo(CraftsmanServiceTO o) {
		
		//2.在按价格(升序)
		int priceValue = 0;
		if(this.getPrices()!=null && o.getPrices()!=null){
			priceValue = this.getPrices().compareTo(o.getPrices());
		}
		//1.先按时间（升序）
		if(StringUtils.isNotEmpty(this.getNearlyAppointmentDate()) && StringUtils.isNotEmpty(o.getNearlyAppointmentDate())) {
			int v = this.getNearlyAppointmentDate().compareTo(o.getNearlyAppointmentDate());
			return v==0? priceValue:v;
		}else {
			return priceValue;
		}
	}
	
}
